import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router);


/*路由懒加载*/
const index = (resolve)=>{
  import('components/index/index').then((module)=>{
    resolve(module)
  })
}
const shopCart = (resolve)=>{
  import('components/cart/shopCart').then((module)=>{
    resolve(module)
  })
}

const user = (resolve)=>{
  import('components/user/user').then((module)=>{
    resolve(module)
  })
}
const setAddress = (resolve)=>{
  import('components/user/setAddress').then((module)=>{
    resolve(module)
  })
}
const brand = (resolve)=>{
  import('components/brand/brand').then((module)=>{
    resolve(module)
  })
}

const into = (resolve)=>{
  import('components/index/into').then((module)=>{
    resolve(module)
  })
}




export default new Router({
  routes: [
    {
      path:'/',
      component:into,
    },
     {
       path:'/index',
       component:index
     },
    {
      path: '/cart',
      component: shopCart
    },
    {
      path: '/user',
      component: user,
      children:[
        {
          path:':id',
          component:setAddress
        }
      ]
    },
    {
      path: '/brand',
      component: brand
    },


  ],
  linkActiveClass: 'active',
})
const router = new Router({
  //这里就是router的全局配置

});
